Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/escape-html

Package Overview
Dependencies
Maintainers
21
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/escape-html

Escape HTML utils.

  • 1.12.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
51K
decreased by-62.02%
Maintainers
21
Weekly downloads
 
Created

What is @wordpress/escape-html?

@wordpress/escape-html is a utility package for escaping HTML entities in strings. It helps prevent XSS (Cross-Site Scripting) attacks by converting special characters into their corresponding HTML entities.

What are @wordpress/escape-html's main functionalities?

Escape HTML

This feature allows you to escape HTML entities in a string, converting special characters like <, >, and & into their corresponding HTML entities.

const { escapeHTML } = require('@wordpress/escape-html');
const unsafeString = '<script>alert("XSS")</script>';
const safeString = escapeHTML(unsafeString);
console.log(safeString); // &lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;

Escape Attribute

This feature allows you to escape HTML attributes, ensuring that special characters are converted to their corresponding HTML entities.

const { escapeAttribute } = require('@wordpress/escape-html');
const unsafeAttribute = '" onmouseover="alert(1)"';
const safeAttribute = escapeAttribute(unsafeAttribute);
console.log(safeAttribute); // &quot; onmouseover=&quot;alert(1)&quot;

Other packages similar to @wordpress/escape-html

Keywords

FAQs

Package last updated on 15 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc